Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tabIndex to mobile nav toggle #1081

Merged

Conversation

millmason
Copy link
Contributor

@millmason millmason commented Jan 15, 2025

Why

The mobile hamburger menu is not currently accessible either by keyboard or screenreader, per issue #978 .

What

As noted by @bacitracin in #978 , the required change is extremely simple. We just add a tabIndex onto the mobile nav toggle and the browser takes care of the rest.

NB

I've added a comment to the ticket which follows this one, #979 , but the menu items for the mobile menu are accessible via tab...but only at the very very end of the tab order, past the bottom of the page. This is because the mobile menu is loaded into the html at the very end of the document, in spite of being located within the Header component in the React code. I don't know why this would be! Possibly not an issue since we want to access them via keyboard up-down arrows anyway, but thought it would be worth noting in case anyone has insights.

Screen captures of current behavior in prod and locally

Current behavior in production:

(User tabs through page, starting with main Clean & Green Philly icon in nav, and tabs directly into the page content without accessing the Menu hamburger toggle.)

Tabbing.past.menu.toggle.on.prod.1.15.25.mov

Adjusted behavior in local with these changes:

(User tabs through page and successfully tabs to Menu hamburger toggle, which opens and closes appropriately on Enter.)

Tabbing.to.menu.toggle.on.local.1.15.25.mov

Steps to test

  • Pull down these changes to your local machine
  • Build changes with usual steps
  • Observe the page at a width < 850px to see mobile menu
  • Tab through the page until you successfully focus the mobile
  • Mobile should display appropriate focus styles (a standard blue halo around the element)
  • On key press Enter or Space the menu should open
  • Hitting the Enter or Space key again should close the menu

Copy link

vercel bot commented Jan 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
vacant-lots-proj ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 3:26pm

Copy link
Collaborator

@CodeWritingCow CodeWritingCow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this PR. I was able to reach the mobile nav button by pressing the "TAB" key on my keyboard. Thanks @millmason!

@CodeWritingCow CodeWritingCow merged commit 2ae8936 into CodeForPhilly:staging Jan 18, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants